package edu.spec.lyq.week09.class2.classroom;

import java.util.ArrayList;
import java.util.List;

/**
 * \* User: 11028
 * \* Date: 2018/10/26
 * \* Time: 9:57
 * \* Description:
 */
public class ListTest {
    public static void main(String[] args) {
        List la = new ArrayList();
        Student sa = new Student("sa","1101");
        Student sb = new Student("sb","1102");
        Student sc = new Student("sc","1103");
        la.add(sa);
        la.add(sb);
        la.add(sc);
        List l = new ArrayList();
        Student s1 = new Student("s1","1111");
        Student s2 = new Student("s2","1112");
        Student s3 = new Student("s3","1113");
        Student s4 = new Student("s4","1114");
        Student s5 = new Student("s5","1115");
        Student s6 = new Student("s6","1116");
        Student s7 = new Student("s7","1117");
        Student s8 = new Student("s8","1118");
        l.addAll(la);
        l.add(s1);
        l.add(s2);
        l.add(s3);
        l.add(s4);
        l.add(s5);
        l.add(s6);
        l.add(s7);
        l.add(s8);
        for (int i=0;i<l.size();i++){
            Student s = (Student) l.get(i);
            System.out.println(s.getName());
            System.out.println(s.getNumber());
        }
        try{                          //异常捕获机制
            Student ss = (Student) l.get(11); //越界
        }catch(Exception e){
            System.out.println(e.toString());
        }
        System.out.println("sadafsa");

        try {
            s1.study(4);
            s1.study(5);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("sadafsa");
    }
}
